//https://leetcode.cn/problems/linked-list-cycle-ii/

struct ListNode* detectCycle(struct ListNode* head) {

    struct ListNode* slow, * fast;
    slow = fast = head;

    while (fast && fast->next)
    {
        slow = slow->next;
        fast = fast->next->next;

        if (slow == fast)
        {
            struct ListNode* meet = slow;
            struct ListNode* star = head;

            while (meet != star)
            {
                meet = meet->next;
                star = star->next;
            }

            return meet;
        }
    }

    return NULL;

}